import 'package:flutter/material.dart';

class Demo7 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Demo7State();
  }
}

class Demo7State extends State<Demo7> {
  @override
  Widget build(BuildContext context) {
    // return new CustomScrollView(
    //     slivers: <Widget>[
    //       //AppBar，包含一个导航栏
    //       SliverAppBar(
    //         pinned: true,
    //         expandedHeight: 250.0,
    //         flexibleSpace: FlexibleSpaceBar(
    //           title: const Text('Demo'),
    //           background: Image.asset(
    //             "./images/avatar.png", fit: BoxFit.cover,),
    //         ),
    //       ),

    //       SliverPadding(
    //         padding: const EdgeInsets.all(8.0),
    //         sliver: new SliverGrid( //Grid
    //           gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
    //             crossAxisCount: 2, //Grid按两列显示
    //             mainAxisSpacing: 10.0,
    //             crossAxisSpacing: 10.0,
    //             childAspectRatio: 4.0,
    //           ),
    //           delegate: new SliverChildBuilderDelegate(
    //                 (BuildContext context, int index) {
    //               //创建子widget      
    //               return new Container(
    //                 alignment: Alignment.center,
    //                 color: Colors.cyan[100 * (index % 9)],
    //                 child: new Text('grid item $index'),
    //               );
    //             },
    //             childCount: 20,
    //           ),
    //         ),
    //       ),
    //       //List
    //       new SliverFixedExtentList(
    //         itemExtent: 50.0,
    //         delegate: new SliverChildBuilderDelegate(
    //                 (BuildContext context, int index) {
    //               //创建列表项      
    //               return new Container(
    //                 alignment: Alignment.center,
    //                 color: Colors.lightBlue[100 * (index % 9)],
    //                 child: new Text('list item $index'),
    //               );
    //             },
    //             childCount: 50 //50个列表项
    //         ),
    //       ),
    //     ],
    //   );
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('GridView'),
      ),
      body: GridView.count(
        crossAxisCount: 3,
        childAspectRatio: 1,
        children: <Widget>[
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
          new Icon(Icons.accessibility_new),
        ],
      ),
    );
  }
}